home *** CD-ROM | disk | FTP | other *** search
-
- Listing 1:
-
- /* complex hyperbolic sine routine intended to test
- argument passing and function returns only. This
- version passes a structure containing two doubles
- and returns a structure of the same type. */
-
- #include <dos.h>
- #include <math.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
-
- #define BIOS_DATA_SEG 0x40
- #define TIMER_DATA 0x6c
- #define TICKS_PER_DAY 0x01800B0L
-
- struct cmplx_nmbr
-
- {
- double real;
- double imag;
- };
-
- long getticks(void);
- struct cmplx_nmbr csinh(struct cmplx_nmbr);
-
- main()
-
- {
- int ctr;
- long start, end;
- struct cmplx_nmbr arg, rtrn;
- start = getticks();
- printf("\n BEGIN AT CLOCK = %ld", start);
- arg.real = 3.0;
- arg.imag = -2.0;
- for(ctr = 1; ctr <= 5000; ++ctr)
- rtrn = csinh(arg);
-
- printf("\n\n REAL RESULT = %lG", rtrn.real);
- printf(" IMAG RESULT = %lG", rtrn.imag);
- end = getticks();
- printf("\n END AT CLOCK = %ld", end);
- printf("\n\n ELAPSED TICKS = %ld", end - start);
- }
-
- struct cmplx_nmbr csinh(struct cmplx_nmbr param)
-
- {
- struct cmplx_nmbr rslt;
- rslt.real = cos(param.imag) * sinh(param.real);
- rslt.imag = sin(param.imag) * cosh(param.real);
- return rslt;
- }
-
-